package com.rds.system.common;

import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 数据操作通用实现Service层
 * @author LiChuanlong
 * @date 2021-08-12
 * @param <T>
 */

@Service
public class AbstractService<T> implements IService<T> {

    @Resource
    private IMappper<T> mapper;

    @Override
    public int insert(T entity) throws Exception {
        return mapper.insert(entity);
    }

    @Override
    public int delete(T entity) throws Exception {
        return mapper.delete(entity);
    }

    @Override
    public int update(T entity) throws Exception {
        return mapper.update(entity);
    }

    @Override
    public T findById(Integer id) throws Exception {
        return mapper.findById(id);
    }

    @Override
    public List<T> findAll(T entity) throws Exception {
        System.out.println("--->>>AbstractService--->>>entity:"+entity);
        return mapper.findAll(entity);
    }

    @Override
    public List<T> filterData(Map<String, Object> map) throws Exception {
        return mapper.filterData(map);
    }
}
